let db = require("../db/index");
// 查询所有投诉建议
exports.all = (req, res) => {
    var sql =
        'select repair.* ,Owner ,Phone,BuildingName,FloorNumber,UnitName,RoomNumber from repair,room,building, unit,floor where building.BuildingID=unit.BuildingID AND unit.UnitID=floor.UnitID and floor.FloorID=room.FloorID and room.RoomID=repair.RoomID ';
    db.query(sql, [], (err, data) => {
        if (err) {
            console.log("出错了", err);
            return res.send("错误" + err.message);
        }
        res.send(data);
    });
};
//修改处理状态
exports.updateState = (req, res) => {
    const {id,state}=req.body
    var sql =
       `update repair set RepairDate='${state}' where ID=${id}`;
    db.query(sql, [], (err, data) => {
        if (err) {
            console.log("出错了", err);
            return res.send("错误" + err.message);
        }
        res.send({
            status:200
        });
    });
};